package com.qf.air.core.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 何星宇
 * @version V1.0
 * @Date 2021/11/9 22:43
 */

@Configuration
public class RabbitMQConfig {
    public static final String AIR_EXCHANGE = "air_exchange";
    public static final String AIR_QUEUE = "air_queue";
    public static final String AIR_ROUTINGKEY = "air.*";

    @Bean
    public Exchange exchange(){
        return ExchangeBuilder.topicExchange(AIR_EXCHANGE).build();
    }
    @Bean
    public Queue queue(){
        return QueueBuilder.durable(AIR_QUEUE).build();
    }
    @Bean
    public Binding binding(Exchange exchange,Queue queue){
        return BindingBuilder.bind(queue).to(exchange).with(AIR_ROUTINGKEY).noargs();
    }
}
